﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jermaine.Cache
{
    /// <summary>
    /// 过期时间类
    /// </summary>
    [Serializable]
    public class ExpiredTime
    {
        public ExpiredTime(DateTime dateTime) {
            this.DeadLine = dateTime;
        }
        
        private ExpiredTime() {
        }

        /// <summary>
        /// 某个时间点过期
        /// </summary>
        /// <param name="expiredTime"></param>
        /// <returns></returns>
        public bool ExpiredAt(ExpiredTime expiredTime) {
            return expiredTime.DeadLine > this.DeadLine;
        }

        /// <summary>
        /// 过期时间
        /// </summary>
        public DateTime DeadLine { get; set; }

        /// <summary>
        /// 是否过期
        /// </summary>
        public bool IsExpired {
            get {
                return System.DateTime.Now > this.DeadLine;
            }
        }
    }
}
